package com.voxel.sense.infomsg.module.firm.details.video;

import android.text.TextUtils;
import android.view.View;

import com.example.com.common.view.recycler.RecyclerAdapter;
import com.voxel.sense.infomsg.R;
import com.voxel.sense.infomsg.utils.JZMediaIjkplayer;

import cn.jzvd.Jzvd;
import cn.jzvd.JzvdStd;
import cyy.example.com.facotry.model.api.response.VideoInfoEntity;

/**
 * Created by ChenYiYao on 2017/11/29.
 */

public class VideoResourceAdapter extends RecyclerAdapter<VideoInfoEntity.institutionWatchsiteVoBean> {

    public VideoResourceAdapter(AdapterListener listener) {
        super(listener);
    }


    @Override
    protected int getItemViewType(int position, VideoInfoEntity.institutionWatchsiteVoBean bodyBean) {
//        return R.layout.item_recycler_video_resource;
        return R.layout.item_recycler_video;
    }

    @Override
    protected ViewHolder onCreateViewHolder(View root, int viewType) {
        return new ViewHolder(root);
    }


    private static class ViewHolder extends RecyclerAdapter.ViewHolder<VideoInfoEntity.institutionWatchsiteVoBean> {
        JzvdStd video_player;

        public ViewHolder(View itemView) {
            super(itemView);
            video_player = itemView.findViewById(R.id.video_player);
        }

        @Override
        protected void onBind(VideoInfoEntity.institutionWatchsiteVoBean bodyBean) {
            String str = TextUtils.isEmpty(bodyBean.getVideoAddrH()) ? bodyBean.getVideoAddrR() : bodyBean.getVideoAddrH();
            //设置播放器参数，第一个参数是地址，第二个是标题，第三个是播放模式，第四个是引擎
            video_player.setUp(str, "监控源" + bodyBean.getWatchSiteName(),
                    Jzvd.SCREEN_NORMAL, JZMediaIjkplayer.class
            );
        }
    }
}
